cc.Class({
    extends: cc.Component,

    properties: {
        spin : cc.Node,
        btn : cc.Node,
        back:cc.Node,
        collectCoin:cc.Node
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        // console.log(1.0 === 1);
        // console.log(1.0000000000000000000001 == 1);
        // console.log(1.000000001 == 1);
        this.back.on('click',function(){
            this.node.active = false;
        },this)
        this.btn.on('click',function(){
         this.startRotate();
        },this)
    },
    init(){
        this.isRotate = false;
        this.spin.stopAllActions();
        this.spin.rotation = 0;
    },
    startRotate(){
        if(this.isRotate) return;
        this.isRotate = true;
        var roBase = 360 *2;
        var arr = [roBase + 72,roBase + 72 * 4 ,roBase + 72 * 2,roBase + 0,roBase + 72 * 3];
        var coinArr = [5,10,20,50,100];
        var ran = Math.random()*10;
        var num = 0;
        if(ran < 4){
            num = 0;
        }else if(ran < 7){
            num = 1;
        }else if(ran < 8.5){
            num = 2;
        }else if(ran < 9.5){
            num = 3;
        }else{
            num = 4;
        }
        // cc.configData.money += coinArr[num];
        // cc.sys.localStorage.setItem("money",cc.configData.money);
        // cc.find("Canvas").emit('money');
        //存储数据
        this.spin.runAction(cc.sequence(cc.rotateBy(2.2,arr[num]).easing(cc.easeOut(1.5)),cc.callFunc(function(){
            this.scheduleOnce(function(){
                this.collectCoin.active = true;
                this.collectCoin.getComponent('spinCoin').init(coinArr[num]);
            },0.5)
        },this)));
    },
    // update (dt) {
    //
    // },
});
